//
//  JSMyGoodsView.swift
//  fho
//
//  Created by 郭颢源 on 2021/4/21.
//

import UIKit

class JSMyGoods1View: UIView, UICollectionViewDelegate, UICollectionViewDataSource {
    let layout = JSCollectionViewLayout()
    override init(frame: CGRect) {
        super.init(frame: frame)

        layout.ver_spacing = 1
        layout.hor_spacing = 1
        layout.numRow = 2
        layout.numCol = 4
        let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout);
        addSubview(collectionView)
        collectionView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(JSCollectionButtonCell.self, forCellWithReuseIdentifier: "JSCollectionButtonCell")
        collectionView.isPagingEnabled = true
        collectionView.backgroundColor = .green
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /**
     返回有几个分组
     */
    func numberOfSections(in collectionView: UICollectionView) -> Int
    {
        return 2
    }
    /**
     返回每个分组有几个数据
     */
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        
        return layout.numRow*layout.numCol
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "JSCollectionButtonCell", for: indexPath)
        
        return cell
    }
    
    
}


